package com.hqyj.hrms.modules.salary.dao;

import com.hqyj.hrms.modules.salary.entity.Salary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author rock
 * @since 2021-10-07
 */
public interface SalaryMapper extends BaseMapper<Salary> {
    @Select("SELECT * FROM salary WHERE month = #{month}")
    @Results({
            @Result(property = "salId", column = "sal_id"),
            @Result(property = "empId", column = "emp_id"),
            @Result(property = "basicSalary", column = "basic_salary"),
            @Result(property = "performanceSalary", column = "performance_salary"),
            @Result(property = "bonus", column = "bonus"),
            @Result(property = "penalty", column = "penalty"),
            @Result(property = "month", column = "month"),
            @Result(property = "totalSal", column = "total_sal")
            })
    HashMap<String,Object> selectByMonth2(String month);

    @Select("SELECT sal_id,emp_id,emp_name,basic_salary,performance_salary,bonus,penalty,month ,basic_salary+performance_salary+bonus-penalty as total_sal FROM salary where emp_id=#{empId} and month=#{month}")
    @Results({
            @Result(property = "salId", column = "sal_id"),
            @Result(property = "empId", column = "emp_id"),
            @Result(property = "basicSalary", column = "basic_salary"),
            @Result(property = "performanceSalary", column = "performance_salary"),
            @Result(property = "bonus", column = "bonus"),
            @Result(property = "penalty", column = "penalty"),
            @Result(property = "month", column = "month"),
            @Result(property = "totalSal", column = "total_sal")
    })
    List<Salary> totalNum(Salary salary);

    @Select("SELECT emp_name,bonus from salary  ORDER BY bonus DESC LIMIT 0,3 ")
    @Results({
            @Result(property = "salId", column = "sal_id"),
            @Result(property = "empId", column = "emp_id"),
            @Result(property = "basicSalary", column = "basic_salary"),
            @Result(property = "performanceSalary", column = "performance_salary"),
            @Result(property = "bonus", column = "bonus"),
            @Result(property = "penalty", column = "penalty"),
            @Result(property = "month", column = "month"),
            @Result(property = "totalSal", column = "total_sal")
    })
   List<Salary> getBonus();

    @Select("SELECT emp_name,penalty from salary  ORDER BY penalty DESC LIMIT 0,3 ")
    @Results({
            @Result(property = "salId", column = "sal_id"),
            @Result(property = "empId", column = "emp_id"),
            @Result(property = "basicSalary", column = "basic_salary"),
            @Result(property = "performanceSalary", column = "performance_salary"),
            @Result(property = "bonus", column = "bonus"),
            @Result(property = "penalty", column = "penalty"),
            @Result(property = "month", column = "month"),
            @Result(property = "totalSal", column = "total_sal")
    })
    List<Salary> getPenalty();
}
